package com.feng.swing.tools;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Properties;

import org.apache.commons.codec.binary.Base64;

import com.feng.security.dsa.SignatureHelper;
import com.feng.security.dsa.SignatureMan;
import com.feng.security.dsa.comon.DSAKeyMan;
import com.feng.security.dsa.comon.SignatureResult;

/**
 * 
 * @author liubingzhao
 * @date 2010-12-14
 */
public class Signature extends javax.swing.JFrame {

	private static final String AMS_CHARACTER_SET_UTF8 = "utf-8";

	/** Creates new form Signature */
	public Signature() {
		initComponents();
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		jTabbedPane1 = new javax.swing.JTabbedPane();
		jPanelToSign = new javax.swing.JPanel();
		jLabel1 = new javax.swing.JLabel();
		jScrollPane3 = new javax.swing.JScrollPane();
		toSignData = new javax.swing.JTextArea();
		jLabel3 = new javax.swing.JLabel();
		jScrollPane2 = new javax.swing.JScrollPane();
		toSignPrivateKey = new javax.swing.JTextArea();
		jLabel4 = new javax.swing.JLabel();
		jScrollPane5 = new javax.swing.JScrollPane();
		toSignResult = new javax.swing.JTextArea();
		toSignBtn = new java.awt.Button();
		jPanelCheckSign = new javax.swing.JPanel();
		jLabel8 = new javax.swing.JLabel();
		jScrollPane7 = new javax.swing.JScrollPane();
		toCheckData = new javax.swing.JTextArea();
		jLabel9 = new javax.swing.JLabel();
		jScrollPane8 = new javax.swing.JScrollPane();
		toCheckSign = new javax.swing.JTextArea();
		jButton1 = new javax.swing.JButton();
		jLabel11 = new javax.swing.JLabel();
		jScrollPane10 = new javax.swing.JScrollPane();
		checkSingResult = new javax.swing.JTextArea();
		jLabel2 = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		checkSignPublicKey = new javax.swing.JTextArea();
		jPanelBase64 = new javax.swing.JPanel();
		jLabel5 = new javax.swing.JLabel();
		jScrollPane4 = new javax.swing.JScrollPane();
		base64Data = new javax.swing.JTextArea();
		jLabel6 = new javax.swing.JLabel();
		base64EncodeBtn = new java.awt.Button();
		base64DecodeBtn = new java.awt.Button();
		jLabel7 = new javax.swing.JLabel();
		jScrollPane6 = new javax.swing.JScrollPane();
		base64Result = new javax.swing.JTextArea();
		base64CharSet = new javax.swing.JComboBox();
		menuBar = new javax.swing.JMenuBar();
		fileMenu = new javax.swing.JMenu();
		openMenuItem = new javax.swing.JMenuItem();
		saveMenuItem = new javax.swing.JMenuItem();
		saveAsMenuItem = new javax.swing.JMenuItem();
		exitMenuItem = new javax.swing.JMenuItem();
		editMenu = new javax.swing.JMenu();
		cutMenuItem = new javax.swing.JMenuItem();
		copyMenuItem = new javax.swing.JMenuItem();
		pasteMenuItem = new javax.swing.JMenuItem();
		deleteMenuItem = new javax.swing.JMenuItem();
		helpMenu = new javax.swing.JMenu();
		contentsMenuItem = new javax.swing.JMenuItem();
		aboutMenuItem = new javax.swing.JMenuItem();
		jCheckBoxMenuItem1 = new javax.swing.JCheckBoxMenuItem();
		menuBar2 = new javax.swing.JMenuBar();
		fileMenu2 = new javax.swing.JMenu();
		openMenuItem2 = new javax.swing.JMenuItem();
		saveMenuItem2 = new javax.swing.JMenuItem();
		saveAsMenuItem2 = new javax.swing.JMenuItem();
		exitMenuItem2 = new javax.swing.JMenuItem();
		editMenu2 = new javax.swing.JMenu();
		cutMenuItem2 = new javax.swing.JMenuItem();
		copyMenuItem2 = new javax.swing.JMenuItem();
		pasteMenuItem2 = new javax.swing.JMenuItem();
		deleteMenuItem2 = new javax.swing.JMenuItem();
		helpMenu2 = new javax.swing.JMenu();
		contentsMenuItem2 = new javax.swing.JMenuItem();
		aboutMenuItem2 = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		jLabel1.setText("\u6570\u636e\uff1a");

		jScrollPane3.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

		toSignData.setColumns(20);
		toSignData.setLineWrap(true);
		toSignData.setRows(5);
		jScrollPane3.setViewportView(toSignData);

		jLabel3.setText("\u79c1\u94a5\uff1a");

		jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

		toSignPrivateKey.setColumns(20);
		toSignPrivateKey.setLineWrap(true);
		toSignPrivateKey.setRows(5);
		jScrollPane2.setViewportView(toSignPrivateKey);

		jLabel4.setText("\u7ed3\u679c\uff1a");

		jScrollPane5.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);

		toSignResult.setColumns(20);
		toSignResult.setLineWrap(true);
		toSignResult.setRows(5);
		jScrollPane5.setViewportView(toSignResult);

		toSignBtn.setActionCommand("button1");
		toSignBtn.setLabel("\u751f\u6210\u7b7e\u540d");
		toSignBtn.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				getSing(evt);
			}
		});

		org.jdesktop.layout.GroupLayout jPanelToSignLayout = new org.jdesktop.layout.GroupLayout(jPanelToSign);
		jPanelToSign.setLayout(jPanelToSignLayout);
		jPanelToSignLayout.setHorizontalGroup(jPanelToSignLayout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(jPanelToSignLayout
						.createSequentialGroup()
						.addContainerGap()
						.add(jPanelToSignLayout
								.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
								.add(org.jdesktop.layout.GroupLayout.TRAILING,
										jPanelToSignLayout
												.createSequentialGroup()
												.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel3).add(jLabel4))
												.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
												.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
														.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
														.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
														.add(jScrollPane5, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)).addContainerGap())
								.add(org.jdesktop.layout.GroupLayout.TRAILING,
										jPanelToSignLayout
												.createSequentialGroup()
												.add(toSignBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).add(245, 245, 245))))
				.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
						jPanelToSignLayout.createSequentialGroup().addContainerGap().add(jLabel1).addContainerGap(536, Short.MAX_VALUE))));
		jPanelToSignLayout
				.setVerticalGroup(jPanelToSignLayout
						.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
						.add(org.jdesktop.layout.GroupLayout.TRAILING,
								jPanelToSignLayout
										.createSequentialGroup()
										.add(11, 11, 11)
										.add(jScrollPane3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
										.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
										.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel3)
												.add(jScrollPane2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
										.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
										.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel4)
												.add(jScrollPane5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 98, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)).add(31, 31, 31)
										.add(toSignBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(39, 39, 39))
						.add(jPanelToSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
								jPanelToSignLayout.createSequentialGroup().addContainerGap().add(jLabel1).add(353, 353, 353))));

		jTabbedPane1.addTab("\u751f\u6210\u7b7e\u540d", jPanelToSign);

		jLabel8.setText("\u6570\u636e\uff1a");

		toCheckData.setColumns(20);
		toCheckData.setLineWrap(true);
		toCheckData.setRows(5);
		jScrollPane7.setViewportView(toCheckData);

		jLabel9.setText("\u7b7e\u540d\uff1a");

		toCheckSign.setColumns(20);
		toCheckSign.setLineWrap(true);
		toCheckSign.setRows(5);
		jScrollPane8.setViewportView(toCheckSign);

		jButton1.setText("\u9a8c\u8bc1");
		jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				checkSign(evt);
			}
		});

		jLabel11.setText("\u7ed3\u679c\uff1a");

		checkSingResult.setColumns(20);
		checkSingResult.setLineWrap(true);
		checkSingResult.setRows(5);
		jScrollPane10.setViewportView(checkSingResult);

		jLabel2.setText("\u516c\u94a5\uff1a");

		checkSignPublicKey.setColumns(20);
		checkSignPublicKey.setLineWrap(true);
		checkSignPublicKey.setRows(5);
		jScrollPane1.setViewportView(checkSignPublicKey);

		org.jdesktop.layout.GroupLayout jPanelCheckSignLayout = new org.jdesktop.layout.GroupLayout(jPanelCheckSign);
		jPanelCheckSign.setLayout(jPanelCheckSignLayout);
		jPanelCheckSignLayout.setHorizontalGroup(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
				jPanelCheckSignLayout
						.createSequentialGroup()
						.add(jPanelCheckSignLayout
								.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
								.add(jPanelCheckSignLayout
										.createSequentialGroup()
										.addContainerGap()
										.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
												.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER).add(jLabel8).add(jLabel9).add(jLabel2)).add(jLabel11))
										.add(jPanelCheckSignLayout
												.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
												.add(jPanelCheckSignLayout
														.createSequentialGroup()
														.add(18, 18, 18)
														.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER)
																.add(jScrollPane7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
																.add(jScrollPane8, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
																.add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)))
												.add(jPanelCheckSignLayout.createSequentialGroup().add(18, 18, 18)
														.add(jScrollPane10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE))))
								.add(jPanelCheckSignLayout.createSequentialGroup().add(229, 229, 229).add(jButton1))).addContainerGap()));
		jPanelCheckSignLayout.setVerticalGroup(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
				jPanelCheckSignLayout
						.createSequentialGroup()
						.addContainerGap()
						.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
								.add(jScrollPane7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).add(jLabel8))
						.add(7, 7, 7)
						.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel9)
								.add(jScrollPane8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 56, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
						.add(jPanelCheckSignLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel2)
								.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 47, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
						.add(jPanelCheckSignLayout
								.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
								.add(jPanelCheckSignLayout.createSequentialGroup()
										.add(jScrollPane10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE).add(32, 32, 32).add(jButton1))
								.add(jLabel11)).addContainerGap(74, Short.MAX_VALUE)));

		jButton1.getAccessibleContext().setAccessibleName("verifyBtn");

		jTabbedPane1.addTab("\u7b7e\u540d\u9a8c\u8bc1", jPanelCheckSign);

		jLabel5.setText("\u6570\u636e\uff1a");

		jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

		base64Data.setColumns(20);
		base64Data.setLineWrap(true);
		base64Data.setRows(5);
		jScrollPane4.setViewportView(base64Data);

		jLabel6.setText("\u7ed3\u679c\uff1a");

		base64EncodeBtn.setLabel("Encode");
		base64EncodeBtn.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				base64Encode(evt);
			}
		});

		base64DecodeBtn.setLabel("Decode");
		base64DecodeBtn.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				base64Decode(evt);
			}
		});

		jLabel7.setText("\u5b57\u7b26\u96c6\uff1a");

		base64Result.setColumns(20);
		base64Result.setLineWrap(true);
		base64Result.setRows(5);
		jScrollPane6.setViewportView(base64Result);

		base64CharSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "UTF-8", "GBK", "ISO-8859-1" }));

		org.jdesktop.layout.GroupLayout jPanelBase64Layout = new org.jdesktop.layout.GroupLayout(jPanelBase64);
		jPanelBase64.setLayout(jPanelBase64Layout);
		jPanelBase64Layout.setHorizontalGroup(jPanelBase64Layout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(jPanelBase64Layout
						.createSequentialGroup()
						.addContainerGap()
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.CENTER).add(jLabel7).add(jLabel5).add(jLabel6))
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
								.add(base64CharSet, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 147, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)
								.add(jScrollPane6, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 482, Short.MAX_VALUE)).addContainerGap(42, Short.MAX_VALUE))
				.add(jPanelBase64Layout.createSequentialGroup().add(136, 136, 136)
						.add(base64EncodeBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.add(146, 146, 146)
						.add(base64DecodeBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(183, Short.MAX_VALUE)));
		jPanelBase64Layout.setVerticalGroup(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
				org.jdesktop.layout.GroupLayout.TRAILING,
				jPanelBase64Layout
						.createSequentialGroup()
						.add(14, 14, 14)
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel7)
								.add(base64CharSet, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel5)
								.add(jScrollPane4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE))
						.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(jLabel6)
								.add(jScrollPane6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 117, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.add(25, 25, 25)
						.add(jPanelBase64Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
								.add(base64EncodeBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(base64DecodeBtn, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
						.add(93, 93, 93)));

		jTabbedPane1.addTab("Base64", jPanelBase64);

		fileMenu.setText("File");

		openMenuItem.setText("Open");
		fileMenu.add(openMenuItem);

		saveMenuItem.setText("Save");
		fileMenu.add(saveMenuItem);

		saveAsMenuItem.setText("Save As ...");
		fileMenu.add(saveAsMenuItem);

		exitMenuItem.setText("Exit");
		exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				exitMenuItemActionPerformed(evt);
			}
		});
		fileMenu.add(exitMenuItem);

		menuBar.add(fileMenu);

		editMenu.setText("Edit");

		cutMenuItem.setText("Cut");
		editMenu.add(cutMenuItem);

		copyMenuItem.setText("Copy");
		editMenu.add(copyMenuItem);

		pasteMenuItem.setText("Paste");
		editMenu.add(pasteMenuItem);

		deleteMenuItem.setText("Delete");
		editMenu.add(deleteMenuItem);

		menuBar.add(editMenu);

		helpMenu.setText("Help");

		contentsMenuItem.setText("Contents");
		helpMenu.add(contentsMenuItem);

		aboutMenuItem.setText("About");
		helpMenu.add(aboutMenuItem);

		jCheckBoxMenuItem1.setSelected(true);
		jCheckBoxMenuItem1.setText("CheckBox");
		helpMenu.add(jCheckBoxMenuItem1);

		menuBar.add(helpMenu);

		fileMenu2.setText("File");

		openMenuItem2.setText("Open");
		fileMenu2.add(openMenuItem2);

		saveMenuItem2.setText("Save");
		fileMenu2.add(saveMenuItem2);

		saveAsMenuItem2.setText("Save As ...");
		fileMenu2.add(saveAsMenuItem2);

		exitMenuItem2.setText("Exit");
		exitMenuItem2.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				exitMenuItemActionPerformed(evt);
			}
		});
		fileMenu2.add(exitMenuItem2);

		menuBar2.add(fileMenu2);

		editMenu2.setText("Edit");

		cutMenuItem2.setText("Cut");
		editMenu2.add(cutMenuItem2);

		copyMenuItem2.setText("Copy");
		editMenu2.add(copyMenuItem2);

		pasteMenuItem2.setText("Paste");
		editMenu2.add(pasteMenuItem2);

		deleteMenuItem2.setText("Delete");
		editMenu2.add(deleteMenuItem2);

		menuBar2.add(editMenu2);

		helpMenu2.setText("Help");

		contentsMenuItem2.setText("Contents");
		helpMenu2.add(contentsMenuItem2);

		aboutMenuItem2.setText("About");
		helpMenu2.add(aboutMenuItem2);

		menuBar2.add(helpMenu2);

		setJMenuBar(menuBar2);

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().addContainerGap().add(jTabbedPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 587, Short.MAX_VALUE).addContainerGap()));
		layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
				layout.createSequentialGroup().add(jTabbedPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 407, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void base64Decode(java.awt.event.MouseEvent evt) {
		String charset = (String) base64CharSet.getSelectedItem();
		System.out.println("<<<Get CharSet:" + charset);
		String data = base64Data.getText();
		System.out.println("<Get data:" + data);
		String result = new String(Base64.decodeBase64(data.getBytes()));
		System.out.println(">>>End result:" + result);
		base64Result.setText(result);
	}

	private void base64Encode(java.awt.event.MouseEvent evt) {
		String charset = (String) base64CharSet.getSelectedItem();
		System.out.println("<<<Get CharSet:" + charset);
		String data = base64Data.getText();
		String result = new String(Base64.encodeBase64(data.getBytes(), true));
		System.out.println(">>>End result:" + result);
		base64Result.setText(result);
	}

	private void checkSign(java.awt.event.MouseEvent evt) {
		// TODO add your handling code here:
	}

	private void getSing(java.awt.event.MouseEvent evt) {
		StringBuffer msg = new StringBuffer();
		String toCheckString = toSignData.getText();
		String priKey = toSignPrivateKey.getText();
		String puKey = checkSignPublicKey.getText();
		System.out.println("<toCheckString is :" + toCheckString);
		System.out.println("<privateKey is :" + priKey);
		System.out.println("<publicKey is :" + puKey);
		SignatureHelper sh = new SignatureHelper();
		Properties properties = sh.getPropertiesFromQueryString(toCheckString, AMS_CHARACTER_SET_UTF8);
		Properties checkSignPro = sh.getPropertiesFromQueryString(toCheckString, AMS_CHARACTER_SET_UTF8);
		SignatureMan sinatureMan = new SignatureMan();
		DSAKeyMan keyMan = new DSAKeyMan();
		SignatureResult rt = keyMan.genDSAKeyPair();
		if (priKey != null && !priKey.equals("")) {
			rt = sinatureMan.dsaSign(properties, priKey, AMS_CHARACTER_SET_UTF8);
			msg.append("Sign:" + rt.getSign());
			try {
				msg.append("\nBase64Encode Sign:" + URLEncoder.encode(rt.getSign(), AMS_CHARACTER_SET_UTF8));
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		toSignResult.setText(msg.toString());
	}

	private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_exitMenuItemActionPerformed
		System.exit(0);
	}// GEN-LAST:event_exitMenuItemActionPerformed

	/**
	 * @param args
	 *            the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new Signature().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JMenuItem aboutMenuItem;
	private javax.swing.JMenuItem aboutMenuItem2;
	private javax.swing.JComboBox base64CharSet;
	private javax.swing.JTextArea base64Data;
	private java.awt.Button base64DecodeBtn;
	private java.awt.Button base64EncodeBtn;
	private javax.swing.JTextArea base64Result;
	private javax.swing.JTextArea checkSignPublicKey;
	private javax.swing.JTextArea checkSingResult;
	private javax.swing.JMenuItem contentsMenuItem;
	private javax.swing.JMenuItem contentsMenuItem2;
	private javax.swing.JMenuItem copyMenuItem;
	private javax.swing.JMenuItem copyMenuItem2;
	private javax.swing.JMenuItem cutMenuItem;
	private javax.swing.JMenuItem cutMenuItem2;
	private javax.swing.JMenuItem deleteMenuItem;
	private javax.swing.JMenuItem deleteMenuItem2;
	private javax.swing.JMenu editMenu;
	private javax.swing.JMenu editMenu2;
	private javax.swing.JMenuItem exitMenuItem;
	private javax.swing.JMenuItem exitMenuItem2;
	private javax.swing.JMenu fileMenu;
	private javax.swing.JMenu fileMenu2;
	private javax.swing.JMenu helpMenu;
	private javax.swing.JMenu helpMenu2;
	private javax.swing.JButton jButton1;
	private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel11;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JLabel jLabel5;
	private javax.swing.JLabel jLabel6;
	private javax.swing.JLabel jLabel7;
	private javax.swing.JLabel jLabel8;
	private javax.swing.JLabel jLabel9;
	private javax.swing.JPanel jPanelBase64;
	private javax.swing.JPanel jPanelCheckSign;
	private javax.swing.JPanel jPanelToSign;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane10;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JScrollPane jScrollPane3;
	private javax.swing.JScrollPane jScrollPane4;
	private javax.swing.JScrollPane jScrollPane5;
	private javax.swing.JScrollPane jScrollPane6;
	private javax.swing.JScrollPane jScrollPane7;
	private javax.swing.JScrollPane jScrollPane8;
	private javax.swing.JTabbedPane jTabbedPane1;
	private javax.swing.JMenuBar menuBar;
	private javax.swing.JMenuBar menuBar2;
	private javax.swing.JMenuItem openMenuItem;
	private javax.swing.JMenuItem openMenuItem2;
	private javax.swing.JMenuItem pasteMenuItem;
	private javax.swing.JMenuItem pasteMenuItem2;
	private javax.swing.JMenuItem saveAsMenuItem;
	private javax.swing.JMenuItem saveAsMenuItem2;
	private javax.swing.JMenuItem saveMenuItem;
	private javax.swing.JMenuItem saveMenuItem2;
	private javax.swing.JTextArea toCheckData;
	private javax.swing.JTextArea toCheckSign;
	private java.awt.Button toSignBtn;
	private javax.swing.JTextArea toSignData;
	private javax.swing.JTextArea toSignPrivateKey;
	private javax.swing.JTextArea toSignResult;
	// End of variables declaration//GEN-END:variables
}